
package com.example.springcloudeurekaserverproducer.mybatis;

import java.util.List;

/**
 * 
 * @ClassName: PageVo
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author lanyuansong
 * @date 2018年7月11日
 * @param <T>
 */
public class PageVo<T> implements java.io.Serializable{

	/** 
	* @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么) 
	*/ 
	private static final long serialVersionUID = 6153648239782567369L;
	
	private int pageNow;
	
	private int pageSize;
	
	private long rows;
	
	private int pageTotal;
	
	private List<T> list;
	
	private T params;
	
	
	public PageVo(int pageNow,int pageSize, T params){
		this.pageNow = pageNow;
		this.pageSize = pageSize;
		this.params = params;
	}
	
	public PageVo(int pageNow,int pageSize,long rows, T params){
		this.pageNow = pageNow;
		this.pageSize = pageSize;
		this.params = params;
		this.rows = rows;
		//计算共多少页
		this.pageTotal = builderPageTotal(pageSize,rows);
	}
	
	public void buildPageTotal(int pageSize,long rows){
		if(rows % pageSize == 0){
			this.pageTotal =  (int)rows / pageSize;
		}else{
			this.pageTotal =  (int)rows / pageSize + 1;
		}
	}
	
	private int builderPageTotal(int pageSize,long rows){
		if(rows % pageSize == 0){
			return (int)rows / pageSize;
		}else{
			return (int)rows / pageSize + 1;
		}
	}


	public int getPageNow() {
		return pageNow;
	}


	public void setPageNow(int pageNow) {
		this.pageNow = pageNow;
	}


	public int getPageSize() {
		return pageSize;
	}


	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}


	public long getRows() {
		return rows;
	}


	public void setRows(long rows) {
		this.rows = rows;
	}


	public int getPageTotal() {
		return pageTotal;
	}


	public void setPageTotal(int pageTotal) {
		this.pageTotal = pageTotal;
	}


	public List<T> getList() {
		return list;
	}


	public void setList(List<T> list) {
		this.list = list;
	}

	public T getParams() {
		return params;
	}

	public void setParams(T params) {
		this.params = params;
	}

	

}
